<template>
    <div>
        <van-cell-group>
            <van-row>
                <van-col span="24" v-for="item in order.goods" :key="item.id">
                    <van-card
                        :num="item.num"
                        :price="item.price"
                        :desc="item.goods_desc"
                        :title="item.goods_name"
                        currency="¥"
                        :thumb="fixUrl(item.goods_img)">
                    </van-card>
                </van-col>
            </van-row>
            <van-cell title="订单号" v-model="order.id"></van-cell>
            <van-cell title="支付金额" v-model="order.amount"></van-cell>
            <van-button @click="pay" type="primary" block>付款</van-button>
        </van-cell-group>
    </div>
</template>

<script>
import {orderPay} from "../../api/order";

export default {
    name: "OrderPay",
    created() {
        this.initOrder()
    },
    data() {
        return {
            showPay: false,
            order: {}
        }
    },
    methods: {
        async pay() {
            let result = await orderPay(this.order);
            if (this.utils.resultBool(result)) {
                this.$toast("支付成功")
                this.$router.push({name: "home"})
            } else {
                this.$toast("支付失败")
            }
        },
        initOrder() {
            this.order = this.$route.params.order;
            console.log(this.order)
        },
        fixUrl(img) {
            return this.utils.fixUrl(img)
        }
    }
}
</script>

<style scoped>

</style>
